package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SetmealMapper extends BaseMapper<Setmeal> {
    @Delete("delete from t_setmeal_checkgroup where SETMEAL_ID = #{setmealId}")
    void deleteCheckgroupsBySetmealId(Integer setmealId);

    @Insert("insert into t_setmeal_checkgroup values(#{setmealId},#{checkgroupId})")
    void addSetmealWithCheckgroup(@Param("setmealId")Integer setmealId,@Param("checkgroupId") Integer checkgroupId);

    @Select("select tcg.id,tcg.name,tcg.remark from t_setmeal_checkgroup tscg,t_checkgroup tcg" +
            " where tscg.checkgroup_id = tcg.id" +
            " and tscg.setmeal_id = #{id}" +
            " and tcg.is_delete = 0")
    List<CheckGroup> findCheckgroupBySetmealId(Integer id);
}
